#include "tracer.h"
#include "options.page.h"
#include "options.dlg.h"
#include "cache.thread.h"
#include "plugin.manager.h"
#include "splash.h"
#include <memory>

#include <QtGui/QtGui>

int main(int argc, char* argv[]) {
	// required to do this here for Mac.
	auto fmt=QSurfaceFormat::defaultFormat();
	fmt.setProfile(QSurfaceFormat::CoreProfile);
	fmt.setVersion(3, 3);
	QSurfaceFormat::setDefaultFormat(fmt);

	QApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true);


	std::unique_ptr<Tracer> tracer{Tracer::create(argc, argv)};

	std::unique_ptr<PluginManager> plugins{PluginManager::instance()};

	std::unique_ptr<OptionsPage> page_cache{OptionsPage::cacheThreadOptions()};
	std::unique_ptr<OptionsPage> page_load{OptionsPage::sessionLoadingOptions()};
	std::unique_ptr<OptionsPage> page_channel{OptionsPage::sessionChannelOptions()};
	std::unique_ptr<OptionsPage> page_comp0{OptionsPage::computeGeneralOptions()};
	std::unique_ptr<OptionsPage> page_comp1{OptionsPage::computeFindOptions()};
	std::unique_ptr<OptionsPage> page_comp2{OptionsPage::computeConnOptions()};
	std::unique_ptr<OptionsPage> page_comp3{OptionsPage::computeRefineOptions()};
	std::unique_ptr<OptionsPage> page_comp4{OptionsPage::computeRefineAutoOptions()};
	std::unique_ptr<OptionsPage> page_view0{OptionsPage::viewerGeneralOptions()};
	std::unique_ptr<OptionsPage> page_view1{OptionsPage::viewerColorOptions()};
	std::unique_ptr<OptionsPage> page_view2{OptionsPage::viewerVolumeOptions()};

	std::unique_ptr<OptionsDlg> opt_dialog{OptionsDlg::instance()};

	std::unique_ptr<CacheThread> cache_thread{CacheThread::instance()};

	std::unique_ptr<Splash> splash{Splash::instance()};

	tracer->start();

	return tracer->exec();
}

